package com.game.screen;

import java.util.List;

import android.os.Message;

import com.game.framwork.itf.Game;
import com.game.framwork.itf.Graphics;
import com.game.framwork.itf.Pixmap;
import com.game.framwork.itf.Screen;
import com.game.framwork.itf.Graphics.PixmapFormat;
import com.game.framwork.itf.Input.TouchEvent;
import com.game_ltdd.Resrouce;

public class MenuScreen extends Screen{
	public MenuScreen(Game game) {
		super(game);
		initResource();
		initSound();
		Resrouce.menugame.play(1, -1);
	}

	private void initSound() {
		Resrouce.menugame = game.getAudio().newSound("MenuTheme.mp3");
	}

	private void initResource() {
		Graphics g = game.getGraphics();
		Resrouce.bgMenu = g.newPixmap("bgmenu.png", PixmapFormat.ARGB8888);
	}

	@Override
	public void update(float deltaTime) {
		processInput(deltaTime);
	}

	private void processInput(float deltaTime) {
		List<TouchEvent> touchEvents = game.getInput().getTouchEvents();
		game.getInput().getKeyEvents();
		int len = touchEvents.size();
		for (int i = 0; i < len; i++) {
			TouchEvent event = touchEvents.get(i);
			if (event.type == TouchEvent.TOUCH_DOWN) {
				touchDownHandle(event, deltaTime);
				continue;
			}
			if (event.type == TouchEvent.TOUCH_DRAGGED) {
				touchDraggedHandle(event, deltaTime);
				continue;
			}
			if (event.type == TouchEvent.TOUCH_UP) {
				touchUpHandle(event, deltaTime);
				continue;
			}
		}
	}
	
	private void touchUpHandle(TouchEvent event, float deltaTime) {
		// TODO Auto-generated method stub
		
	}

	private void touchDraggedHandle(TouchEvent event, float deltaTime) {
		// TODO Auto-generated method stub
		
	}

	private void touchDownHandle(TouchEvent event, float deltaTime) {
		game.jumScreen(SCREEN_BATTLE);
	}

	@Override
	public void present(float deltaTime, Graphics g) {
		g.drawPixmap(Resrouce.bgMenu, 0, 0);
	}

	@Override
	public void pause() {
		
	}

	@Override
	public void resume() {
		
	}

	@Override
	public void dispose() {
		
	}

}
